import axios from 'axios'

const axiosInstance = axios.create({
  baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
  timeout: 10000
})

axiosInstance.interceptors.request.use(
  (config) => {
    // 在请求前进行一些操作，如添加token
    return config
  },
  (error) => {
    return Promise.reject(error)
  }
)

axiosInstance.interceptors.response.use(
  (response) => {
    return response.data
  },
  (error) => {
    // 处理响应错误
    return Promise.reject(error)
  }
)

export default axiosInstance
